package com.example.deepseek.backend.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import java.time.LocalDateTime;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class ChatMessage {

    private String sender; // user 或 ai
    private String content; // 文本内容
    private boolean isFile; // 是否为文件消息
    private FileInfo fileInfo; // 文件信息
    private LocalDateTime timestamp; // 时间戳

    // 文本消息构造函数
    public ChatMessage(String sender, String content) {
        this.sender = sender;
        this.content = content;
        this.isFile = false;
        this.timestamp = LocalDateTime.now();
    }

    // 文件消息构造函数
    public ChatMessage(String sender, FileInfo fileInfo) {
        this.sender = sender;
        this.content = "";
        this.isFile = true;
        this.fileInfo = fileInfo;
        this.timestamp = LocalDateTime.now();
    }

    // 默认构造函数，用于JSON序列化
    public ChatMessage() {
        this.timestamp = LocalDateTime.now();
    }
    
    // Getter and Setter methods
    public String getSender() {
        return sender;
    }
    
    public void setSender(String sender) {
        this.sender = sender;
    }
    
    public String getContent() {
        return content;
    }
    
    public void setContent(String content) {
        this.content = content;
    }
    
    public boolean isFile() {
        return isFile;
    }
    
    public void setFile(boolean file) {
        isFile = file;
    }
    
    public FileInfo getFileInfo() {
        return fileInfo;
    }
    
    public void setFileInfo(FileInfo fileInfo) {
        this.fileInfo = fileInfo;
    }
    
    public LocalDateTime getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(LocalDateTime timestamp) {
        this.timestamp = timestamp;
    }
}